<?php

require_once WP_PLUGIN_DIR . '/diapucp-events/defines.php' ;
require_once DPEM_SMB_PATH . '/smb_basefield.php' ;

class smartmeta_select extends smb_basefieldbox {
    public function  __construct($fields){
        $this->set_fields($fields);
        $this->set_inputid( $fields['id'] . '_select_field' );
    }

    public static function build_me( $fields, &$new_field_object ){
        $new_field_object = new smartmeta_select($fields);
    }

    public function show(){
        $value = $this->fetch_value();
        ?>
        <td>
            <label for="<?php echo $this->inputid; ?>"><?php echo $this->fields['name']; ?></label>
        </td>
        <td>
            <select name="<?php echo $this->inputid;?>" class="select" id="<?php echo $this->inputid;?>">
            <?php foreach ($this->fields['options'] as $opt_value=>$opt_name): ?>
                <option <?php selected($value, $opt_value)?> value="<?php echo $opt_value?>"><?php echo $opt_name?></option>
            <?php endforeach ?>
            </select>
        </td>
        <?php
    }

    public function save($post_id){
        $data = $_POST[ $this->inputid ];
        if ( empty( $data ) and isset($this->fields['default'] ) ){ $data = $this->fields['default']; }
        $data = wp_strip_all_tags($data);
        smb_basefieldbox::set($this->fields['id'], $data);
    }

}

?>



